<%--
 *  File:    VisitPlanAssistConfirm.jsp
 *  @Author: ChinaLiu
 *  Date:    2009-10-26

 *  Copyright (C) 2000 - 2009 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.OvalLabel" %>
<%@ page import="com.oval.util.OvalCustomMessage" %>
<%@ page import="com.oval.util.OvalCustomColumn" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  String privilegeCode = "H0257";
  String strTableName = "v_visitplanassistconfirm2";
  String strModuleName = "SFE";
  String contextPath = request.getContextPath();
%>



<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@include file="/inc/Print.inc"%>
<%@ include file="/inc/FrmDefault.inc"%>
<%@ include file="/inc/LocationDefault.inc" %>
<html>
<head>
<title>VisitPlanAssistConfirm</title>
<PageFlow:CheckPageFlow pageName="p_visitplanassistconfirm"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%
Vector totalsummary = (Vector) pageContext.getAttribute("visitplandetails");
if (totalsummary == null)
    totalsummary = new Vector();   
%>
<script>
function clickProd(id)
{
  document.actionsummaryform.newvisitplandetailid.value = id;
}
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(actionsummaryform,actionvalue,orderbyname);
  editform.action = "VisitPlanAssistConfirm.jsp?<%= OvalTools.randomURL() %>";  
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function page_agree(){
  var details=eval("document.actionsummaryform.sss");
  if(isNullChecked(details))
  {
    alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD") %>");
    return;
  }
    var ids="";
	eval("document.actionsummaryform.newvisitplandetailid").value=" ";
    for (var i=1; i<=<%=totalsummary.size()%>;  i++)
  	{
  		var checkboxs =document.getElementById("action"+i);
  	    if(checkboxs.checked)
	  	   {
	  	   	if(ids=="")
	  	   	{
	  	   	ids=checkboxs.value;
	  	  
	  	   	}else{
	  	   	ids=ids+","+checkboxs.value;
	  	   
	  	   	}
	  	   }
  	   
  	}
  	eval("document.actionsummaryform.newvisitplandetailid").value=ids;
   document.actionsummaryform.assistconfirm.value="1";
   var frm = document.actionsummaryform;
   frm.actionname.value = "agree";
   frm.target = "_self";
   isRunning = true;
   frm.submit();

}
function page_refuse(){
   var details=eval("document.actionsummaryform.sss");
  if(isNullChecked(details))
  {
    alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD") %>");
    return;
  }
    var ids="";
	eval("document.actionsummaryform.newvisitplandetailid").value=" ";
    for (var i=1; i<=<%=totalsummary.size()%>;  i++)
  	{
  		var checkboxs =document.getElementById("action"+i);
  	    if(checkboxs.checked)
	  	   {
	  	   	if(ids=="")
	  	   	{
	  	   	ids=checkboxs.value;
	  	  
	  	   	}else{
	  	   	ids=ids+","+checkboxs.value;
	  	   
	  	   	}
	  	   }
  	   
  	}
  	eval("document.actionsummaryform.newvisitplandetailid").value=ids;
   document.actionsummaryform.assistconfirm.value="2";
   if(document.actionsummaryform.newvisitplandetailid==null)
   return;
    var frm = document.actionsummaryform;
   frm.actionname.value = "refuse";
   frm.target = "_self";
   isRunning = true;
   frm.submit();

}

</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
 <form name="actionsummaryform" method="post" action="../Dispatcher">
      <input type="hidden" name="pagename" value="p_visitplanassistconfirm">
      	<input type="hidden" name="actionname">
      	 <%@ include file="/inc/PageLocation.inc" %> 
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
    <td>
      <table width="100%" border="0" cellspacing="0">
        <tr>
          <td class="summary_top" colspan="2" ></td>
        </tr>
	<%@ include file="/inc/SummarySearch.inc" %>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" width="100%">

        <tr class="deepblue-left">
          <td width="5%" class="title_center">&nbsp;</td>
          <td><%= label.getLabelName("L_CustomerInfo") %></td>
          <td width="20%" class="title_center"><%= label.getLabelName("L_Sales") %></td>
          <td width="20%" class="title_center"><%= label.getLabelName("L_VisitPlanDate") %></td>
          <td width="20%" class="title_center"><%= label.getLabelName("L_Status") %></td>
       <!--   <td width="10%" class="title_center"><%= label.getLabelName("L_LastVisitDate") %></td>
          <td width="10%" class="title_center"><%= label.getLabelName("L_CountVisitOfMonth ") %></td>-->
        </tr>
        <%int i=0; %>
            <%
                        /*
                        Vector totalsummary = (Vector) pageContext.getAttribute("visitplandetails");
                        if (totalsummary == null)
                            totalsummary = new Vector();  
                        */
                            boolean bHasChecked = false;
                             String strClassType = new String("");
                            
               %>
	 <logic:iterate id="actionhash" collection="<%=totalsummary%>" indexId="orderid">
	 <%
	 HashMap oneDetail = (HashMap)pageContext.getAttribute("actionhash"); 
	 java.text.SimpleDateFormat sdf2Time=new java.text.SimpleDateFormat("HH:mm");
          			Date dStart=(Date)oneDetail.get("planstarttime");
          			Date dEnd=(Date)oneDetail.get("planendtime");
          			Integer PlanDetailStatus=(Integer)oneDetail.get("plandetailstatus");
          			String sStart="";
          			String sEdit="";
          			if(dStart!=null)
          			sStart=sdf2Time.format(dStart);
          			if(dEnd!=null)
          			sEdit=sdf2Time.format(dEnd);
	 String strIsChecked ="";
	 		            if(i%2 == 1)
            {
              strClassType = "td-listrom";
            }else{
              strClassType = "none";
            }
	      if(!bHasChecked)
            {
              strIsChecked = "checked";
              bHasChecked = true; %>
                        <input type="hidden" name="newvisitplandetailid" value="<custom:write property="visitplandetailid" name="actionhash"/>">
                        <input type="hidden" name="contactid" value="<custom:write property="contactid2" name="actionhash"/>">
            <%   }
              i++; 
	 %>
	 <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull(strClassType)%>'"  onClick="javascript:clickProd('<custom:write property="visitplandetailid" name="actionhash"/>');" class="<%=JspHelper.filterNull( strClassType )%>" >
	 <td>
	 <%
	 //out.print(PlanDetailStatus.intValue());
	 if(PlanDetailStatus.intValue() ==40){ %>
	 <input id="action<%=JspHelper.filterNull(i)%>" type="checkbox" name="sss"  Class="normalradio" value="<custom:write property="visitplandetailid" name="actionhash"/>"/>
	 <%}else{ %>
	 <input id="action<%=JspHelper.filterNull(i)%>" type="checkbox" name="sss"  Class="normalradio" value="<custom:write property="visitplandetailid" name="actionhash"/>" disabled="disabled"/>
	 <%} %>
	 </td>
	 <td>
	 <%pageContext.setAttribute("displayflag","view");%>
	 <custom:selectdic name="actionhash" property="activitytype" dictType="ZVisitProcessType" /> 
	 <custom:write property="orgcode" name="actionhash" nbsp="true" />&nbsp;
	 <custom:write property="orgname" name="actionhash" nbsp="true" />&nbsp;
	 <custom:write property="valuename" name="actionhash" nbsp="true" />
	 </td>
	 <td><custom:write property="contactname" name="actionhash" nbsp="true" /></td>
	 <td><custom:write property="planvisitdate" name="actionhash" nbsp="true" /></td>
	 <td><custom:write property="plandetailstatus" name="actionhash" nbsp="true" dictType="Status"/></td>
	<!-- <td><custom:write property="lastvisitdate" name="actionhash" nbsp="true" /></td>
	 <td><custom:write property="count_org" name="actionhash" nbsp="true" /></td>  --> 

	 </tr>
	 </logic:iterate>
	          <%@ include file="/inc/SummaryAction.inc" %>
    </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="summary_top" ></td>
        </tr>
        <tr>
          <td class="td_center">

           <input type="hidden" name="assistconfirm">
          <a onclick="page_agree();"><custom:button type="1" label="L_Agree" imgsrc="new.gif" border="0" style="width:60"/></a>
          <a onclick="page_refuse()"><custom:button type="1" label="L_Refuse" imgsrc="new.gif" border="0" style="width:60"/></a>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
 </form>
</body>
</html>